package day01.日期类;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * @author feng
 * @Date 2022/1/3 10:10
 * 时间日期精确类
 * 日历类
 * Calendar抽象类，
 * 1.多态调用
 * 2.获得默认实例对象
 */
public class Test01 {
    public static void main(String[] args) {
        Calendar calendar = new GregorianCalendar();
        //获取年份
        System.out.println(calendar.get(Calendar.YEAR));
        //月份,注意:取得月份+1
        System.out.println(calendar.get(Calendar.MONTH) + 1);
        //几号
        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
        // 获得这是今年的第几天
        System.out.println("现在是今年第" + calendar.get(Calendar.DAY_OF_YEAR) + "天");
        // 获得今天周几
        System.out.println("现在是星期：" + (calendar.get(Calendar.DAY_OF_WEEK) - 1));

        // 获得今天是这个月的第几周
        System.out.println("现在是第：" + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH) + "周");
        //当前时间时钟数
        System.out.println(calendar.get(Calendar.HOUR_OF_DAY));
        //分钟
        System.out.println(calendar.get(Calendar.MINUTE));
        //秒
        System.out.println(calendar.get(Calendar.SECOND));

    }
}
